import axios from "axios";

// 创建axios实例
const api = axios.create({
    baseURL: "/api",
    timeout: 3000
});


// 配置响应拦截器
api.interceptors.response.use(resp => {
    let result = resp.data;

    if (result.success) {
        return result;
    } else {
        return Promise.reject(result.msg || "服务器异常");
    }
}, error => {
    return Promise.reject(error);
});


export default api;